{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0\n",
       "1    1\n",
       "2    2\n",
       "3    3\n",
       "4    4\n",
       "dtype: int64"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pd.Series(np.arange(5), \n",
    "              index = np.arange(5)[::1],\n",
    "              dtype='int64')\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    False\n",
       "1     True\n",
       "2    False\n",
       "3     True\n",
       "4     True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.isin([1,3,4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1    1\n",
       "3    3\n",
       "4    4\n",
       "dtype: int64"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[s.isin([1,3,4])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0  a    0\n",
       "   b    1\n",
       "   c    2\n",
       "1  a    3\n",
       "   b    4\n",
       "   c    5\n",
       "dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2 = pd.Series(np.arange(6),\n",
    "               index = pd.MultiIndex.from_product([[0,1], ['a', 'b', 'c']]))\n",
    "s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1  a    3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2.iloc[s2.index.isin([(1,'a'), (2,'b')])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3    3\n",
       "4    4\n",
       "dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[s>2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "dates = pd.date_range('2023-4-9', periods=8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "      <th>d</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2023-04-09</th>\n",
       "      <td>-0.108726</td>\n",
       "      <td>-0.754242</td>\n",
       "      <td>0.707058</td>\n",
       "      <td>-0.157080</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-10</th>\n",
       "      <td>0.952099</td>\n",
       "      <td>0.786674</td>\n",
       "      <td>1.510640</td>\n",
       "      <td>0.026692</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-11</th>\n",
       "      <td>0.112236</td>\n",
       "      <td>-0.810061</td>\n",
       "      <td>-0.585985</td>\n",
       "      <td>1.529463</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-12</th>\n",
       "      <td>0.419064</td>\n",
       "      <td>0.177232</td>\n",
       "      <td>-0.812833</td>\n",
       "      <td>0.761297</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-13</th>\n",
       "      <td>0.267396</td>\n",
       "      <td>0.657542</td>\n",
       "      <td>0.042976</td>\n",
       "      <td>-1.483093</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-14</th>\n",
       "      <td>2.562877</td>\n",
       "      <td>-0.688512</td>\n",
       "      <td>0.960851</td>\n",
       "      <td>1.550041</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-15</th>\n",
       "      <td>-1.512091</td>\n",
       "      <td>-1.743895</td>\n",
       "      <td>-0.102110</td>\n",
       "      <td>0.399421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023-04-16</th>\n",
       "      <td>-0.636160</td>\n",
       "      <td>-1.157769</td>\n",
       "      <td>0.215253</td>\n",
       "      <td>0.730540</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   a         b         c         d\n",
       "2023-04-09 -0.108726 -0.754242  0.707058 -0.157080\n",
       "2023-04-10  0.952099  0.786674  1.510640  0.026692\n",
       "2023-04-11  0.112236 -0.810061 -0.585985  1.529463\n",
       "2023-04-12  0.419064  0.177232 -0.812833  0.761297\n",
       "2023-04-13  0.267396  0.657542  0.042976 -1.483093\n",
       "2023-04-14  2.562877 -0.688512  0.960851  1.550041\n",
       "2023-04-15 -1.512091 -1.743895 -0.102110  0.399421\n",
       "2023-04-16 -0.636160 -1.157769  0.215253  0.730540"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame(np.random.randn(8,4),\n",
    "                  index = dates,\n",
    "                  columns=['a','b','c','d'])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
